
<h3>related object filters</h3>

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'qvfilters-grid',
        'dataProvider'=>$qvfmodel,
	'selectionChanged'=>'updateEditFormFilters',
        'columns'=>array(
                array(
                    'value'=>'$data[\'objfil_id\']',
                    'type'=>'raw',
                    'htmlOptions'=>array(
                            'style'=>'width:50px',
                            'onClick'=>"jQuery.ajax({'type':'POST','url':'".Yii::app()->createUrl('//qvmapping/loadObjectValues')."','data':{'docName':$('#qvo_docName').val(),'id':$(this).parent().children('.qvf_id').text()},'success':function(html){jQuery('#qvv_values').html(html)}});",
                    ),
                    'name'=>'objfil_id',
                ),
                array(
                    'value'=>'$data[\'qvf_id\']',
                    'type'=>'raw',
                    'htmlOptions'=>array(
                            'style'=>'width:30px',
                            'class'=>'qvf_id',
                            'onClick'=>"jQuery.ajax({'type':'POST','url':'".Yii::app()->createUrl('//qvmapping/loadObjectValues')."','data':{'docName':$('#qvo_docName').val(),'id':$(this).parent().children('.qvf_id').text()},'success':function(html){jQuery('#qvv_values').html(html)}});",
                    ),
                    'name'=>'qvf_id',
                ),
                array(
                    'value'=>'$data[\'qvf\'][\'qvf_fieldName\']',
                    'type'=>'raw',
                    'htmlOptions'=>array(
                            'style'=>'width:150px',
                            'onClick'=>"jQuery.ajax({'type':'POST','url':'".Yii::app()->createUrl('//qvmapping/loadObjectValues')."','data':{'docName':$('#qvo_docName').val(),'id':$(this).parent().children('.qvf_id').text()},'success':function(html){jQuery('#qvv_values').html(html)}});",
                    ),
                    'name'=>'QV FieldName',
                ),
		array(
                    'value'=>'$data[\'filter\']',
                    'type'=>'raw',
                    'htmlOptions'=>array(
                            'onClick'=>"jQuery.ajax({'type':'POST','url':'".Yii::app()->createUrl('//qvmapping/loadObjectValues')."','data':{'docName':$('#qvo_docName').val(),'id':$(this).parent().children('.qvf_id').text()},'success':function(html){jQuery('#qvv_values').html(html)}});",
                    ),
                    'name'=>'Filter',
                ),
		array(
			'class'=>'CButtonColumn',
                        'template'=>'{delete}',
		),
	),
)); ?>

<script type="text/javascript">
    
$('#mySubViewFormFilters').hide();

function updateEditFormFilters(target_id){

    $('#Notification').jnotifyAddMessage({
	        text: 'Loading filters...',
	        permanent: false,
	        showIcon: true
   });

    var id =$.fn.yiiGridView.getSelection(target_id);

    $('#fil_save_button').attr('value', (id > 0 ? 'update' : 'create'));

    $.getJSON('<?php echo Yii::app()->createUrl("//objectqvfilters/subviewload"); ?>'+'&id='+id,
			function(data) {
				$('#ObjectQvfilters_filter').val(data.filter);
                                $('#ObjectQvfilters_objfil_id').val(data.objfil_id);
                                $('#ObjectQvfilters_objectlink_id').val(data.objectlink_id);
                                $('#ObjectQvfilters_qvf_id').val(data.qvf_id);
                        });
                        
   return false;
}

</script>

<div class="floatingbar">

<?php
$this->widget('zii.widgets.jui.CJuiButton',
	array(
		'name'=>'filterbutton',
                'caption'=>'new filter',
		'value'=>'ase',
		'onclick'=>'js:function(){
                    $("#ObjectQvfilters_objectlink_id").val($("#Objectlink_objectlink_id").val());
                    $("#ObjectQvfilters_filter").val("");
                    $("#ObjectQvfilters_objfil_id").val(0);
                    jQuery.ajax({"type":"POST","url":"'.Yii::app()->createUrl('//qvmapping/loadObjectValues').'","data":{"docName":"'.strtoupper(Qvobjects::model()->findByPK(Objects::model()->findByPK($_GET['id'])->qvo_id)->qvo_docName).'","id":0},"success":function(html){jQuery("#qvv_values").html(html)}});
                    $("#fil_save_button").attr("value","Create");
                }',
		)       
        );
?>

</div>


<div id="mySubViewFormFilters">

    <?php $this->renderPartial('//objectqvfilters/_form', array('filmodel'=>ObjectQvfilters::model())); ?>

</div>